package com.itheima.utils;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * ClassName:DateUtils
 * Package:com.itheima.utils
 * Description:日期转换工具类
 * Date:2020/3/10 0:33
 * User: snow
 */
public class DateUtils {

	// 日期转换成字符串
	public static String date2String(Date date,String str){
		SimpleDateFormat dateFormat = new SimpleDateFormat(str);
		String format = dateFormat.format(date);
		return format;
	}
	// 字符串转换成日期
	public static Date string2Date(String str,String pattern)throws ParseException {
		SimpleDateFormat dateFormat = new SimpleDateFormat(pattern);
		Date  parse = dateFormat.parse(str);
		return parse;
	}
}

